#pragma  once
/*
 * singleton declare.  
 */

// singleton macro declare.
#define DECLARE_SINGLETON(cls)          \
private:                                \
	static cls* m_pInstance;            \
	                                    \
protected:                              \
    cls(const cls &rhs) = delete;       \
                                        \
public:                                 \
	static cls* Instance() {            \
	    if (m_pInstance) {              \
		    return m_pInstance;         \
		} else {                        \
		    m_pInstance = new cls;      \
			return m_pInstance;         \
		}                               \
	}                                   \
	                                    \
	static bool CreateInstance() {      \
	    if (m_pInstance == nullptr) {   \
	       m_pInstance = new cls;       \
	    }                               \
	    return (nullptr != m_pInstance);\
	}                                   \
	                                    \
	static void DestroyInstance() {     \
	   if (m_pInstance != nullptr) {    \
	       delete m_pInstance;          \
	       m_pInstance = nullptr;       \
	   }                                \
	}                                   \
                                        \
    static cls* instance() {            \
       return m_pInstance;              \
     }

// singleton implement
#define IMPLEMENT_SINGLETON(cls)        \
	cls* cls::m_pInstance = nullptr;
